$(document).ready(function(){
	$('.jsCourseAction').click(function() {
		switch ($(this).attr('id')) {
			case 'jsCourseDelete':
				$('#jsDataType').val('delete');
				break;
			case 'jsCourseUndelete':
				$('#jsDataType').val('undelete');
				break;
			case 'jsCourseAuthentication':
				$('#jsDataType').val('authenticate');
				break;
			case 'jsCourseNotAuthentication':
				$('#jsDataType').val('notauthenticate');
				break;
			case 'jsCourseRecommend':
				$('#jsDataType').val('recommend');
				break;
			case 'jsCourseUnRecommend':
				$('#jsDataType').val('unrecommend');
				break;
		}
		if ($('input[name="data[id][]"]:checked').length == 0) {
			alert('Please choose at least 1 course');
			return false;
		}
		$(this).closest('form').submit();
		return false;
	});
	
	$('.btnTransaction').click(function(){
		switch($(this).attr('id')){
			case 'btnDeleteTransaction':
				$('#hdTransactionType').val('delete');
				$('#hdTransactionValue').val(1);
				break;
			case 'btnUnDeleteTransaction':
				$('#hdTransactionType').val('delete');
				$('#hdTransactionValue').val(0);
				break;
			case 'btnSuccessTransaction':
				$('#hdTransactionType').val('status');
				$('#hdTransactionValue').val(1);
				break;
			case 'btnFaultTransaction':
				$('#hdTransactionType').val('status');
				$('#hdTransactionValue').val(0);
				break;		
		}
		if ($('input[name="data[id][]"]:checked').length == 0) {
			alert('Please choose at least 1 transaction');
			return false;
		}
		$(this).closest('form').submit();
		return false;
	});
	
	$('.jsBtnBack').unbind('click').click(function() {
		window.history.back();
		return false;
	});

	if ($('#calendar').length > 0) {
		$('#calendar').fullCalendar({
			events: urlEvent,
			eventClick: function(event) {
				if (event.hasOwnProperty('readmore') && event.readmore) {
					$.colorbox({href: urlEvent + '?all=1&start=' + event.start_params + '&end=' + event.end_params});
				} else if(event.hasOwnProperty('url')) {
					window.open(event.url, '_blank');
				}
				return false;
			}
		});
	}
});